//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.orphan.supplier.controller;

import com.orphan.supplier.po.Tender;
import com.orphan.supplier.service.ITenderService;
import com.orphan.supplier.vo.TenderVO;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping({"/tender"})
public class TenderController {
    @Resource
    private ITenderService tenderService;

    public TenderController() {
    }

    @GetMapping({"/list"})
    public List<TenderVO> list() {
        List<Tender> list = this.tenderService.list();
        List<TenderVO> result = new ArrayList();
        Iterator var3 = list.iterator();

        while(var3.hasNext()) {
            Tender t = (Tender)var3.next();
            result.add(new TenderVO(t));
        }

        return result;
    }

    @GetMapping({"/thisUser/{username}"})
    public List<Tender> thisUser(@PathVariable("username") String username) {
        return this.tenderService.thisUser(username);
    }

    @GetMapping({"/tenderInfo/{number}"})
    public Tender tenderInfo(@PathVariable("number") String number) {
        return this.tenderService.getByNum(number);
    }

    @GetMapping({"/addTender/{price}/{providedAmount}/{call}/{supplier}/{goods}"})
    public boolean addTender(@PathVariable("price") Double price,
                             @PathVariable("providedAmount") int providedAmount,
                             @PathVariable("call") String call,
                             @PathVariable("supplier") String username,
                             @PathVariable("goods") int goodsId) {
        return this.tenderService.add(price, providedAmount, call, username, goodsId);
    }

    @GetMapping({"/update/{tenderNumber}/{price}/{amount}"})
    public boolean updateTender(@PathVariable("tenderNumber") String tenderNumber, @PathVariable("price") Double price,@PathVariable("amount") int amount) {
        return this.tenderService.updateTender(tenderNumber, price,amount);
    }

    @GetMapping({"/cancel/{tenderNumber}"})
    public boolean cancelTender(@PathVariable("tenderNumber") String tenderNumber) {
        return this.tenderService.cancel(tenderNumber);
    }
}
